﻿<Window 
    x:Class="MainWindow" 
    x:ClassModifier="Friend"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:awe="http://schemas.awesomium.com/winfx"
    xmlns:local="clr-namespace:VBWPFSample"
    xmlns:shell="clr-namespace:Microsoft.Windows.Shell;assembly=Microsoft.Windows.Shell"
    WindowStartupLocation="CenterScreen" 
    Icon="/VBWPFSample;component/Awesomium.ico" 
    TextOptions.TextFormattingMode="Display"
    RenderOptions.ClearTypeHint="Enabled"
    Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
    Width="800"
    Height="600">
    <Window.Title>
        <Binding Path="Title" ElementName="Browser" StringFormat="Awesomium VB WPF Sample - {0}" />
    </Window.Title>
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />

        <DrawingImage x:Key="HomeImage">
            <DrawingImage.Drawing>
                <DrawingGroup>
                    <DrawingGroup.Children>
                        <GeometryDrawing Geometry="F1 M 9.46933,0.573334L 0.480001,10.0653C 0.160001,10.4013 6.05981e-007,10.792 6.05981e-007,11.2933L 6.05981e-007,11.2933C 6.05981e-007,11.7413 0.160001,12.1907 0.480001,12.5253L 0.480001,12.5253C 0.798667,12.8587 1.224,13.0267 1.70267,13.0267L 1.70267,13.0267C 2.12933,13.0267 2.55467,12.8587 2.87467,12.5253L 10.64,4.31467L 18.46,12.5253C 18.7773,12.8587 19.1507,13.0267 19.6827,13.0267L 19.6827,13.0267C 20.108,13.0267 20.4813,12.8587 20.8547,12.5253L 20.8547,12.5253C 21.1173,12.2507 21.236,11.9 21.2987,11.536L 21.2987,11.032C 21.236,10.6533 21.1173,10.34 20.8547,10.0653L 11.864,0.573334C 11.4907,0.238668 11.1187,0.069334 10.64,0.069334L 10.64,0.069334C 10.2147,0.069334 9.788,0.238668 9.46933,0.573334 Z M 10.2147,6.268L 3.192,13.6947L 3.192,19.392C 3.192,20.4813 3.61467,21.1293 4.45733,21.3333L 8.3,21.3333L 8.3,13.528C 8.3,13.4187 8.352,13.2507 8.45867,13.192L 8.45867,13.192C 8.512,13.0813 8.67067,13.0267 8.77867,13.0267L 12.4493,13.0267C 12.6093,13.0267 12.7147,13.0813 12.768,13.192L 12.768,13.192C 12.8747,13.2507 12.9267,13.4187 12.9267,13.528L 12.9267,21.3333L 16.7693,21.3333C 17.6133,21.1293 18.036,20.4813 18.036,19.392L 18.036,13.584L 11.0653,6.324C 10.9053,6.1 10.8,5.98934 10.64,5.98934L 10.64,5.98934C 10.5347,5.98934 10.3747,6.1 10.2147,6.268 Z ">
                            <GeometryDrawing.Brush>
                                <LinearGradientBrush StartPoint="0.499828,0.000168633" EndPoint="0.499828,1.00228">
                                    <LinearGradientBrush.GradientStops>
                                        <GradientStop Color="#FF96989B" Offset="0"/>
                                        <GradientStop Color="#FF96989B" Offset="0.00561523"/>
                                        <GradientStop Color="#FF797B7E" Offset="0.504768"/>
                                        <GradientStop Color="#FF5C5E61" Offset="1"/>
                                    </LinearGradientBrush.GradientStops>
                                </LinearGradientBrush>
                            </GeometryDrawing.Brush>
                        </GeometryDrawing>
                    </DrawingGroup.Children>
                </DrawingGroup>
            </DrawingImage.Drawing>
        </DrawingImage>

        <DrawingImage x:Key="ReloadImage">
            <DrawingImage.Drawing>
                <DrawingGroup>
                    <DrawingGroup.Children>
                        <GeometryDrawing Geometry="F1 M 3.116,3.08267C 1.01867,5.156 0,7.70534 0,10.668L 0,10.668C 0,13.6307 1.01867,16.1187 3.116,18.1933L 3.116,18.1933C 5.21467,20.2653 7.79067,21.3333 10.7867,21.3333L 10.7867,21.3333C 13.784,21.3333 16.3,20.2653 18.3987,18.1933L 18.3987,18.1933C 19.536,17.1253 20.3147,15.94 20.8533,14.5787L 15.8213,12.6827C 15.5813,13.2733 15.1027,13.8667 14.6227,14.4013L 14.6227,14.4013C 13.544,15.4667 12.284,16 10.7867,16L 10.7867,16C 9.288,16 8.03067,15.4667 6.952,14.4013L 6.952,14.4013C 5.93333,13.3933 5.39333,12.148 5.39333,10.668L 5.39333,10.668C 5.39333,9.18534 5.93333,7.94134 6.952,6.87467L 6.952,6.87467C 8.03067,5.868 9.288,5.33333 10.7867,5.33333L 10.7867,5.33333C 12.224,5.33333 13.484,5.808 14.5027,6.756L 14.6227,6.87467L 12.5827,8.88933C 12.4027,9.00667 12.4027,9.12533 12.3427,9.244L 12.3427,9.244C 12.284,9.42267 12.284,9.48267 12.3427,9.54134L 12.3427,9.54134C 12.4027,9.65867 12.4627,9.71867 12.5827,9.71867L 20.6147,9.77867C 20.6747,9.77867 20.7947,9.71867 20.9133,9.71867L 20.9133,9.71867C 21.0333,9.6 21.0933,9.48267 21.2133,9.364L 21.2133,9.364C 21.2733,9.244 21.3333,9.12533 21.3333,9.06667L 21.2133,1.12667L 21.2133,1.06667C 21.2133,0.949335 21.1533,0.949335 21.0933,0.890669L 21.0933,0.890669C 21.0933,0.890669 21.0333,0.890669 21.0333,0.830669L 21.0333,0.830669C 20.9733,0.830669 20.9133,0.890669 20.7947,0.890669L 20.7947,0.890669C 20.6747,0.949335 20.4947,1.008 20.4347,1.12667L 18.3987,3.14L 18.336,2.964C 16.24,1.008 13.784,0.00133514 10.7867,0.00133514L 10.7867,0.00133514C 7.79067,0.00133514 5.21467,1.008 3.116,3.08267 Z ">
                            <GeometryDrawing.Brush>
                                <LinearGradientBrush StartPoint="0.500366,-0.00525066" EndPoint="0.500366,0.994968">
                                    <LinearGradientBrush.GradientStops>
                                        <GradientStop Color="#FFE56E24" Offset="0"/>
                                        <GradientStop Color="#FF96989B" Offset="0.00561523"/>
                                        <GradientStop Color="#FF797B7E" Offset="0.504454"/>
                                        <GradientStop Color="#FF5C5E61" Offset="1"/>
                                    </LinearGradientBrush.GradientStops>
                                </LinearGradientBrush>
                            </GeometryDrawing.Brush>
                        </GeometryDrawing>
                    </DrawingGroup.Children>
                </DrawingGroup>
            </DrawingImage.Drawing>
        </DrawingImage>

    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid MinHeight="30" Margin="0,0,0,5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="30" />
                <ColumnDefinition Width="30" />
                <ColumnDefinition Width="30" />
                <ColumnDefinition Width="30" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Button 
                Margin="3" 
                Command="BrowseBack"
                CommandTarget="{Binding ElementName=Browser}"
                Padding="0">
                <Path 
                    Margin="0,0,2,0" 
                    Stroke="Black" 
                    Fill="Black" 
                    Data="M 4,0 L 0,3.5 L 4,7 Z" 
                    Opacity="0.5"/>
            </Button>
            <Button 
                Grid.Column="1" 
                Margin="3" 
                Command="BrowseForward"
                CommandTarget="{Binding ElementName=Browser}"
                Padding="0">
                <Path 
                    Margin="2,0,0,0" 
                    Stroke="Black" 
                    Fill="Black" 
                    Data="M 0,0 L 4,3.5 L 0,7 Z" 
                    Opacity="0.5"/>
            </Button>
            <Button 
                Grid.Column="2" 
                Margin="3" 
                Command="Refresh"
                CommandTarget="{Binding ElementName=Browser}"
                Padding="0">
                <Image 
                    Width="12" 
                    Height="12"
                    HorizontalAlignment="Center" 
                    VerticalAlignment="Center" 
                    Stretch="Uniform" 
                    Source="{StaticResource ReloadImage}"/>
            </Button>
            <Button 
                Grid.Column="3" 
                Margin="3" 
                Command="BrowseHome"
                CommandTarget="{Binding ElementName=Browser}"
                Padding="0">
                <Image 
                    Width="12" 
                    Height="12"
                    Margin="0,0,0,2"
                    HorizontalAlignment="Center" 
                    VerticalAlignment="Center" 
                    Stretch="Uniform" 
                    Source="{StaticResource HomeImage}"/>
            </Button>
            <TextBox 
                x:Name="AddressBox"
                Grid.Column="4" 
                Margin="3"
                VerticalContentAlignment="Center"
                Text="{Binding Source, ElementName=Browser, UpdateSourceTrigger=Explicit}"/>
        </Grid>
        <Border Grid.Row="1" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
            <awe:WebControl x:Name="Browser" Source="http://www.google.com" />
        </Border>
        <Border 
            Grid.Row="2" 
            Height="30"
            Margin="3,0"
            BorderThickness="0,1,0,0" 
            BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <local:GlowTextBlock 
                    VerticalAlignment="Center"
                    Text="{Binding TargetURL, ElementName=Browser}" 
                    TextTrimming="CharacterEllipsis"/>
                <ProgressBar 
                    Grid.Column="1"
                    HorizontalAlignment="Right"
                    VerticalAlignment="Center"
                    Height="20"
                    MinWidth="120"
                    Margin="3,0"
                    Opacity="0.8"
                    IsIndeterminate="{Binding IsLoadingPage, ElementName=Browser}"
                    Visibility="{Binding IsLoadingPage, ElementName=Browser, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                <local:GlowTextBlock 
                    Grid.Column="2" 
                    VerticalAlignment="Center" 
                    Margin="3,0" 
                    Text="Zoom:"/>
                <Slider 
                    Grid.Column="3"
                    DataContext="{Binding ElementName=Browser}"
                    Minimum="10" 
                    Maximum="400"
                    Width="120"
                    VerticalAlignment="Center"
                    Value="{Binding Zoom}" 
                    AutoToolTipPlacement="TopLeft"
                    IsSnapToTickEnabled="True"
                    IsMoveToPointEnabled="True" 
                    SmallChange="1" 
                    LargeChange="10" 
                    TickFrequency="10" 
                    Focusable="False">
                    <Slider.ContextMenu>
                        <ContextMenu DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}">
                            <MenuItem Command="{x:Static awe:WebControlCommands.ResetZoom}" CommandTarget="{Binding}" />
                        </ContextMenu>
                    </Slider.ContextMenu>
                </Slider>
            </Grid>
        </Border>
    </Grid>
</Window>
